<?php

 require_once('/var/myscheduler/nusoap/lib/nusoap.php');

 $wsdl=new soapclient('http://cdmo.baruch.sc.edu/webservices/xmldatarequest.cfc?wsdl');

 #echo $wsdl->call('exportSingleParamXML',array('tbl'=>'niwolwq','numrecs'=>'4','param'=>'Temp'));
 #echo 'Single Parameter Response: <xmp>'.$wsdl->response.'</xmp>';

 $station_list = array();  

 $pg_conn=pg_connect("dbname=rcoos user=rcoos password=123rcoos");
 $result = pg_query ($pg_conn, "SELECT platform.short_name from platform,organization where platform.organization_id = organization.row_id and organization.short_name='nerrs'");

 while ($row = pg_fetch_row($result)) {
      array_push($station_list,$row[0]);
 }
 pg_close($pg_conn); 

 foreach ($station_list as $station_id) {

   $wsdl->call('exportAllParamsXML',array('tbl'=>$station_id,'numrecs'=>'4'));
   #echo 'All Parameter Response: <xmp>'.$wsdl->response.'</xmp>';

   $file_out = '/tmp/nerrs/cdmo_'.$station_id;
   $fh = fopen($file_out.'.txt', 'w') or die("can't open file");
   fwrite($fh, $wsdl->response);
   fclose($fh);
   #print $wsdl->response;
   `perl filter_CDMO.pl $file_out`;
 }

?>
